import { computed } from "vue";
import { mapGetters, useStore } from "vuex";

export function useGetter(mapper) {
  const store = useStore();

  const storeStateFns = mapGetters(mapper);

  const storeState = {};
  Object.keys(storeStateFns).forEach((fnKey) => {
    const fn = storeStateFns[fnKey].bind({ $store: store });
    storeState[fnKey] = computed(fn);
  });

  return storeState
}
